import request from '@/router/axios'

export function fetchDeviceTree(query) {
  return request({
    url: '/entrance-guard/guardDevice/listTree',
    method: 'get',
    params: query
  })
}
export function put(obj) {
  return request({
    url: '/entrance-guard/guardDevice/',
    method: 'put',
    data: obj
  })
}
export function add(obj) {
  return request({
    url: '/entrance-guard/guardDevice/',
    method: 'post',
    data: obj
  })
}
export function del(id) {
  return request({
    url: '/entrance-guard/guardDevice/' + id,
    method: 'delete'
  })
}

export function fetchGuardTree(roleId) {
  return request({
    url: '/entrance-guard/guardRoleDevice/getByRole?roleId=' + roleId,
    method: 'get'
  })
}

export function guardRoleUpd(roleId, deviceIds) {
  return request({
    url: '/entrance-guard/guardRoleDevice/guardRoleUpd',
    method: 'post',
    params: {
      roleId: roleId,
      deviceIds: deviceIds
    }
  })
}

export function syncByDeviceId(deviceId) {
  return request({
    url: '/entrance-guard/guardDevice/syncByDeviceId?deviceId=' + deviceId,
    method: 'get'
  })
}
export function deviceInit(deviceId) {
  return request({
    url: '/entrance-guard/guardDevice/deviceInit?deviceId=' + deviceId,
    method: 'get'
  })
}
